package com.sharengo.sms.Controller;

import com.sharengo.sms.Sms;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Map;

@RestController
public class SmsController extends BaseController {
    @Autowired
    private Sms sms;

    @GetMapping(path = "/sms/send")
    public Map<String, Object> sendSms(@RequestParam(value = "mobile") String mobile
            ,@RequestParam(value = "content") String content){
        try {
            String result=sms.sendSameContentPost(mobile,content,1);
            anwser.put("state","1");
            anwser.put("result",result);
        } catch (IOException e) {
            e.printStackTrace();
            putFalse();
            putMessage("网络或者读写错误"+e.getMessage());
            anwser.put("state","0");
        }
        return anwser;
    }
}
